package com.jk.smartelderlycare.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.jk.smartelderlycare.dao.SysStoreMapper;
import com.jk.smartelderlycare.dto.SysStore;
import com.jk.smartelderlycare.pojo.PagedResponse;
import com.jk.smartelderlycare.service.SysStoreService;
import com.jk.smartelderlycare.utils.PaginationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author xw
 * @version 1.0
 * @ClassName SysStoreServiceImpl
 * @program: smart-elderly-care-demo
 * @description: TODO
 * @date 2024/12/5 14:54
 */
@Service
public class SysStoreServiceImpl implements SysStoreService {
    @Autowired
    private SysStoreMapper sysStoreMapper;



    @Override
    public PagedResponse<SysStore> findSysStorePaginationList(SysStore sysStore, Integer pageNum, Integer pageSize) {
        Page<SysStore> page = new Page<>(pageNum,pageSize);
        IPage<SysStore> pageList = sysStoreMapper.findSysStorePaginationList(page,sysStore);
        return PaginationUtil.getPagedResponse(pageList.getRecords(),pageNum,pageSize,pageList.getTotal());
    }

    @Override
    public List<SysStore> findStoreList() {
        return sysStoreMapper.selectList(null);
    }

    @Override
    public void addStore(SysStore sysStore) {
        sysStoreMapper.insert(sysStore);
    }


}
